//
//  PlayerSelect.m
//  Memory Mania
//
//  Created by Sanket Karkhanis on 2/20/12.
//  Copyright 2012 University of Southern California. All rights reserved.
//

#import "PlayerSelect.h"
#import "ModeSelect.h"
#import "MainMenu.h"

@implementation PlayerSelect


+(id) scene
{
    CCScene *scene = [CCScene node];
    PlayerSelect *layer = [PlayerSelect node];
    [scene addChild:layer];
    return  scene;
    
}


- (id)init
{
    self = [super init];
    if (self) {
        CCMenuItem *singleplayer = [CCMenuItemFont itemFromString:@"Single Player" target:self selector:@selector(onSingleplayer:)];
        CCMenuItem *twoplayer = [CCMenuItemFont itemFromString:@"Two Players" target:self selector:@selector(onTwoplayer:)];
        CCMenuItem *back = [CCMenuItemFont itemFromString:@"Back" target:self selector:@selector(onBack:)];       singleplayer.scale = 3.0f;
        twoplayer.scale = 3.0f;
        back.scale = 2.0f;
        
        //background
        CCSprite *PSBg = [CCSprite spriteWithFile:@"nickwheeleroz_Desert_Rose.jpg"];		
        PSBg.anchorPoint = ccp(0.5,0.5);
        PSBg.position = ccp(512,384);
		//PSBg.opacity = 70;        
        [self addChild:PSBg z:0 tag:1];   
        
        //play.position = ccp(700,200);
        CCMenu *menu = [CCMenu menuWithItems:singleplayer, twoplayer, back, nil];

        [menu alignItemsVerticallyWithPadding:50.0f];
        [self addChild:menu];
        
        // Initialization code here.
    }
    
    return self;
}

-(void) onSingleplayer: (id) sender
{
    NSLog(@"To play screen3");
    [[CCDirector sharedDirector] replaceScene:[CCTransitionShrinkGrow transitionWithDuration:1.0 scene:[ModeSelect node]]];    
}

-(void) onTwoplayer: (id) sender
{
    NSLog(@"To play screen3");
    [[CCDirector sharedDirector] replaceScene:[CCTransitionShrinkGrow transitionWithDuration:1.0 scene:[ModeSelect node]]]; 
}
//add
-(void) onBack: (id) sender
{
    NSLog(@"Back to MainMenu");
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:1.0 scene:[MainMenu node]]]; 
}

@end
